package com.ndp.fb.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by infi.he on 2016/3/18.
 */
public interface KeysConstant {

    static interface GaConstant {
        String transactions = "transactions"; //交易但数量
        String transactionsPerSession = "transactionsPerSession"; //交易但数量
        String transactionRevenue = "transactionRevenue"; //交易收入
        String revenuePerTransaction = "revenuePerTransaction"; //平均每笔交易收入
        String sessions = "sessions"; //点击率
        String goal1Completions = "goal1Completions"; //第一目标，加入购物车
        String goal1ConversionRate = "goal1ConversionRate"; //第一目标，加入率
        String userGender = "userGender"; //性别
        String deviceCategory = "deviceCategory"; //设备
        String countryIsoCode = "countryIsoCode"; //国家码
        String userAgeBracket = "userAgeBracket"; //年龄
        String keyword = "keyword"; //关键字
        String date = "date"; //关键字

        String productSku = "productSku"; //产品sku
    }

    String[] Fetch_All_Ga_Fields = {"sessions", "transactions", "transactionsPerSession", "transactionRevenue", "revenuePerTransaction",
            "goal1Completions", "goal1ConversionRate"};

    /**
     * 所有分组字段
     */
    String[] ALL_GROUP_FIELDS = {"adIds", "adNames", "spend", "day", "webSite", "device", "placement", "adType", "adId", "adName", "adSetId", "adSetName", "campaignId", "campaignName", "account", "age", "gender", "country", "optimizationGoal", "billingEvent", "autoBid", "productId"};
//    String[] GA_GROUP_FIELDS = {"device", "age", "gender", "country", "day"};

    Map<String, FbColumnKey> GA_GROUP_FIELDS_MAP = new HashMap() {
        {
            put("device", FbColumnKey.device);
            put("age", FbColumnKey.age);
            put("gender", FbColumnKey.gender);
            put("country", FbColumnKey.country);
            put("day", FbColumnKey.day);
            put("adNames", FbColumnKey.adNames);
            put("ad", FbColumnKey.adNames);
        }
    };

    String[] GA_GROUP_ADNAMES_CONVERTE_DIMENSIONS = new String[]{"placement", "adType", "ad", "adSet", "campaign", "account", "optimizationGoal", "billingEvent", "autoBid"};
    String[] GA_GROUP_SKU_CONVERTE_DIMENSIONS = new String[]{"productId"};

    static enum FbColumnKey {
        // 第一期返回字段开始
        clicks(GaConstant.sessions),
        cpc(""),
        cart(GaConstant.goal1Completions),
        cartCR(GaConstant.goal1ConversionRate),
        pays(GaConstant.transactions),
        cr(GaConstant.transactionsPerSession),
        cpa(""),
        orderAmount(GaConstant.transactionRevenue),
        orderPrice(GaConstant.revenuePerTransaction),
        roi(""),
        checkout(GaConstant.goal1Completions),

        productId(GaConstant.productSku),

        /// 分组相关
        day(GaConstant.date), //日期
        device(GaConstant.deviceCategory), //设备
        country(GaConstant.countryIsoCode), //国家
        age(GaConstant.userAgeBracket),    //年龄
        gender(GaConstant.userGender), //性别
        adNames(GaConstant.keyword); //广告名称

        FbColumnKey(String sessions) {
            gakey = sessions;
        }

        public String getGakey() {
            return gakey;
        }

        public static FbColumnKey getFbConstant(String gaKey) {
            FbColumnKey[] values = FbColumnKey.values();
            for (FbColumnKey value : values) {
                if (value.getGakey().equals(gaKey)) {
                    return value;
                }
            }
            return null;
        }

        private String gakey;
    }
}
